import 'package:safetymonitor/generated/json/base/json_convert_content.dart';
import 'package:safetymonitor/app/data/entities/application/day_info_list_entity.dart';

DayInfoListEntity $DayInfoListEntityFromJson(Map<String, dynamic> json) {
  final DayInfoListEntity dayInfoListEntity = DayInfoListEntity();
  final List<DayInfoListPlanInfo>? planInfo = (json['planInfo'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<DayInfoListPlanInfo>(e) as DayInfoListPlanInfo).toList();
  if (planInfo != null) {
    dayInfoListEntity.planInfo = planInfo;
  }
  final String? dutyDate = jsonConvert.convert<String>(json['dutyDate']);
  if (dutyDate != null) {
    dayInfoListEntity.dutyDate = dutyDate;
  }
  return dayInfoListEntity;
}

Map<String, dynamic> $DayInfoListEntityToJson(DayInfoListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['planInfo'] = entity.planInfo?.map((v) => v.toJson()).toList();
  data['dutyDate'] = entity.dutyDate;
  return data;
}

extension DayInfoListEntityExtension on DayInfoListEntity {
  DayInfoListEntity copyWith({
    List<DayInfoListPlanInfo>? planInfo,
    String? dutyDate,
  }) {
    return DayInfoListEntity()
      ..planInfo = planInfo ?? this.planInfo
      ..dutyDate = dutyDate ?? this.dutyDate;
  }
}

DayInfoListPlanInfo $DayInfoListPlanInfoFromJson(Map<String, dynamic> json) {
  final DayInfoListPlanInfo dayInfoListPlanInfo = DayInfoListPlanInfo();
  final int? createTime = jsonConvert.convert<int>(json['createTime']);
  if (createTime != null) {
    dayInfoListPlanInfo.createTime = createTime;
  }
  final int? updateTime = jsonConvert.convert<int>(json['updateTime']);
  if (updateTime != null) {
    dayInfoListPlanInfo.updateTime = updateTime;
  }
  final String? creator = jsonConvert.convert<String>(json['creator']);
  if (creator != null) {
    dayInfoListPlanInfo.creator = creator;
  }
  final String? updater = jsonConvert.convert<String>(json['updater']);
  if (updater != null) {
    dayInfoListPlanInfo.updater = updater;
  }
  final bool? deleted = jsonConvert.convert<bool>(json['deleted']);
  if (deleted != null) {
    dayInfoListPlanInfo.deleted = deleted;
  }
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    dayInfoListPlanInfo.id = id;
  }
  final int? companyId = jsonConvert.convert<int>(json['companyId']);
  if (companyId != null) {
    dayInfoListPlanInfo.companyId = companyId;
  }
  final String? companyName = jsonConvert.convert<String>(json['companyName']);
  if (companyName != null) {
    dayInfoListPlanInfo.companyName = companyName;
  }
  final int? scheduleConfigId = jsonConvert.convert<int>(json['scheduleConfigId']);
  if (scheduleConfigId != null) {
    dayInfoListPlanInfo.scheduleConfigId = scheduleConfigId;
  }
  final String? scheduleName = jsonConvert.convert<String>(json['scheduleName']);
  if (scheduleName != null) {
    dayInfoListPlanInfo.scheduleName = scheduleName;
  }
  final int? dutyStartDate = jsonConvert.convert<int>(json['dutyStartDate']);
  if (dutyStartDate != null) {
    dayInfoListPlanInfo.dutyStartDate = dutyStartDate;
  }
  final int? dutyEndDate = jsonConvert.convert<int>(json['dutyEndDate']);
  if (dutyEndDate != null) {
    dayInfoListPlanInfo.dutyEndDate = dutyEndDate;
  }
  final int? dutyPersonId = jsonConvert.convert<int>(json['dutyPersonId']);
  if (dutyPersonId != null) {
    dayInfoListPlanInfo.dutyPersonId = dutyPersonId;
  }
  final String? dutyPerson = jsonConvert.convert<String>(json['dutyPerson']);
  if (dutyPerson != null) {
    dayInfoListPlanInfo.dutyPerson = dutyPerson;
  }
  final String? dutyPersonPhone = jsonConvert.convert<String>(json['dutyPersonPhone']);
  if (dutyPersonPhone != null) {
    dayInfoListPlanInfo.dutyPersonPhone = dutyPersonPhone;
  }
  final dynamic personScheduleType = json['personScheduleType'];
  if (personScheduleType != null) {
    dayInfoListPlanInfo.personScheduleType = personScheduleType;
  }
  final String? personScheduleTypeCode = jsonConvert.convert<String>(json['personScheduleTypeCode']);
  if (personScheduleTypeCode != null) {
    dayInfoListPlanInfo.personScheduleTypeCode = personScheduleTypeCode;
  }
  final int? dutyLeaderId = jsonConvert.convert<int>(json['dutyLeaderId']);
  if (dutyLeaderId != null) {
    dayInfoListPlanInfo.dutyLeaderId = dutyLeaderId;
  }
  final String? dutyLeader = jsonConvert.convert<String>(json['dutyLeader']);
  if (dutyLeader != null) {
    dayInfoListPlanInfo.dutyLeader = dutyLeader;
  }
  final String? dutyLeaderPhone = jsonConvert.convert<String>(json['dutyLeaderPhone']);
  if (dutyLeaderPhone != null) {
    dayInfoListPlanInfo.dutyLeaderPhone = dutyLeaderPhone;
  }
  final dynamic leaderScheduleType = json['leaderScheduleType'];
  if (leaderScheduleType != null) {
    dayInfoListPlanInfo.leaderScheduleType = leaderScheduleType;
  }
  final dynamic leaderScheduleTypeCode = json['leaderScheduleTypeCode'];
  if (leaderScheduleTypeCode != null) {
    dayInfoListPlanInfo.leaderScheduleTypeCode = leaderScheduleTypeCode;
  }
  final int? dutyType = jsonConvert.convert<int>(json['dutyType']);
  if (dutyType != null) {
    dayInfoListPlanInfo.dutyType = dutyType;
  }
  final String? dutyRoomLandline = jsonConvert.convert<String>(json['dutyRoomLandline']);
  if (dutyRoomLandline != null) {
    dayInfoListPlanInfo.dutyRoomLandline = dutyRoomLandline;
  }
  return dayInfoListPlanInfo;
}

Map<String, dynamic> $DayInfoListPlanInfoToJson(DayInfoListPlanInfo entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['createTime'] = entity.createTime;
  data['updateTime'] = entity.updateTime;
  data['creator'] = entity.creator;
  data['updater'] = entity.updater;
  data['deleted'] = entity.deleted;
  data['id'] = entity.id;
  data['companyId'] = entity.companyId;
  data['companyName'] = entity.companyName;
  data['scheduleConfigId'] = entity.scheduleConfigId;
  data['scheduleName'] = entity.scheduleName;
  data['dutyStartDate'] = entity.dutyStartDate;
  data['dutyEndDate'] = entity.dutyEndDate;
  data['dutyPersonId'] = entity.dutyPersonId;
  data['dutyPerson'] = entity.dutyPerson;
  data['dutyPersonPhone'] = entity.dutyPersonPhone;
  data['personScheduleType'] = entity.personScheduleType;
  data['personScheduleTypeCode'] = entity.personScheduleTypeCode;
  data['dutyLeaderId'] = entity.dutyLeaderId;
  data['dutyLeader'] = entity.dutyLeader;
  data['dutyLeaderPhone'] = entity.dutyLeaderPhone;
  data['leaderScheduleType'] = entity.leaderScheduleType;
  data['leaderScheduleTypeCode'] = entity.leaderScheduleTypeCode;
  data['dutyType'] = entity.dutyType;
  data['dutyRoomLandline'] = entity.dutyRoomLandline;
  return data;
}

extension DayInfoListPlanInfoExtension on DayInfoListPlanInfo {
  DayInfoListPlanInfo copyWith({
    int? createTime,
    int? updateTime,
    String? creator,
    String? updater,
    bool? deleted,
    int? id,
    int? companyId,
    String? companyName,
    int? scheduleConfigId,
    String? scheduleName,
    int? dutyStartDate,
    int? dutyEndDate,
    int? dutyPersonId,
    String? dutyPerson,
    String? dutyPersonPhone,
    dynamic personScheduleType,
    String? personScheduleTypeCode,
    int? dutyLeaderId,
    String? dutyLeader,
    String? dutyLeaderPhone,
    dynamic leaderScheduleType,
    dynamic leaderScheduleTypeCode,
    int? dutyType,
    String? dutyRoomLandline,
  }) {
    return DayInfoListPlanInfo()
      ..createTime = createTime ?? this.createTime
      ..updateTime = updateTime ?? this.updateTime
      ..creator = creator ?? this.creator
      ..updater = updater ?? this.updater
      ..deleted = deleted ?? this.deleted
      ..id = id ?? this.id
      ..companyId = companyId ?? this.companyId
      ..companyName = companyName ?? this.companyName
      ..scheduleConfigId = scheduleConfigId ?? this.scheduleConfigId
      ..scheduleName = scheduleName ?? this.scheduleName
      ..dutyStartDate = dutyStartDate ?? this.dutyStartDate
      ..dutyEndDate = dutyEndDate ?? this.dutyEndDate
      ..dutyPersonId = dutyPersonId ?? this.dutyPersonId
      ..dutyPerson = dutyPerson ?? this.dutyPerson
      ..dutyPersonPhone = dutyPersonPhone ?? this.dutyPersonPhone
      ..personScheduleType = personScheduleType ?? this.personScheduleType
      ..personScheduleTypeCode = personScheduleTypeCode ?? this.personScheduleTypeCode
      ..dutyLeaderId = dutyLeaderId ?? this.dutyLeaderId
      ..dutyLeader = dutyLeader ?? this.dutyLeader
      ..dutyLeaderPhone = dutyLeaderPhone ?? this.dutyLeaderPhone
      ..leaderScheduleType = leaderScheduleType ?? this.leaderScheduleType
      ..leaderScheduleTypeCode = leaderScheduleTypeCode ?? this.leaderScheduleTypeCode
      ..dutyType = dutyType ?? this.dutyType
      ..dutyRoomLandline = dutyRoomLandline ?? this.dutyRoomLandline;
  }
}